<!--
 * @Date: 2023-10-09 15:38:54
 * @LastEditTime: 2023-10-09 17:41:48
 * 介绍:
-->
<script lang="ts" setup>
import { apiTaskArbitrationAgree, ApiTaskDetails } from "@@/api/wk/index";
import { WkTaskStatus } from "@@/enum/globalEnum";
import { showDialog } from "vant";
import applyArbitrate from "./applyArbitrate.vue";

const props = defineProps<{
  details: ApiTaskDetails.Data;
  id: number;
  refresh: () => void;
}>();
const btnLoading = reactive({
  taskArbitrationAgree: false,
});
const { t } = useI18n();
function taskArbitrationAgree() {
  btnLoading.taskArbitrationAgree = true;
  showDialog({
    title: t("tong-yi-pan-jue"),
    message: t("yao-tong-yi-pan-jue-ma"),
  })
    .then(() => apiTaskArbitrationAgree({ id: props.id }))
    .then((res) => {
      btnLoading.taskArbitrationAgree = false;
      if (!res) return;
      props.details.status = WkTaskStatus.COMPLETE;
    })
    .catch(() => (btnLoading.taskArbitrationAgree = false));
}
</script>
<template>
  <div class="flex-J-SB" style="gap: var(--gap-md)">
    <applyArbitrate :="props" />
    <Rbutton
      @click="taskArbitrationAgree"
      :loading="btnLoading.taskArbitrationAgree"
      bg="var(--C-LG1)" borderStyle="none"
      :size="'large'"
      
    >
      {{ $t("tong-yi-pan-jue") }}
    </Rbutton>
  </div>
</template>
<style lang="scss" scoped></style>
